Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 3430 - new packagings edit page based on api v3 #3475

Merged
merged 4 commits into from
Dec 27, 2022

Conversation

monsieurtanuki
Copy link
Contributor

New file:

  • edit_new_packagings.dart: Edit display of a product packagings (the new api V3 version).

Impacted files:

  • background_task_details.dart: added specific save method call for api V3
  • edit_product_page.dart: added call to new page EditNewPackagings
  • ocr_packaging_helper.dart: minor unrelated refactoring
  • paged_user_product_query.dart: specific field list
  • product_query.dart: upgraded to api V3; added field PACKAGINGS; added specific field list for user-related searches (they do not support PACKAGINGS)
  • product_refresher.dart: upgraded to api V3
  • simple_input_page.dart: minor refactoring
  • simple_input_widget.dart: refactoring about making the autocomplete widget reusable
  • up_to_date_changes.dart: added new field packagings; minor unrelated refactoring

What

  • New "edit packagings page" based on api v3
  • Those packagings are split in material, shape, recycling status and number of units
  • I coded quickly without much regard for UI or localization - that would have to be done in a second step.

Screenshot

Edit product: "NEW PACKAGINGS" new page
Capture d’écran 2022-12-27 à 13 42 27 Capture d’écran 2022-12-27 à 13 42 55

Fixes bug(s)

New file:
* `edit_new_packagings.dart`: Edit display of a product packagings (the new api V3 version).

Impacted files:
* `background_task_details.dart`: added specific save method call for api V3
* `edit_product_page.dart`: added call to new page `EditNewPackagings`
* `ocr_packaging_helper.dart`: minor unrelated refactoring
* `paged_user_product_query.dart`: specific field list
* `product_query.dart`: upgraded to api V3; added field `PACKAGINGS`; added specific field list for user-related searches (they do not support `PACKAGINGS`)
* `product_refresher.dart`: upgraded to api V3
* `simple_input_page.dart`: minor refactoring
* `simple_input_widget.dart`: refactoring about making the autocomplete widget reusable
* `up_to_date_changes.dart`: added new field `packagings`; minor unrelated refactoring
@teolemon
Copy link
Member

Great for the quick turnaround @monsieurtanuki 👏
Are Weight of one empty unit (g)and Quantity of product contained per unit causing any issues ?

@codecov-commenter
Copy link

codecov-commenter commented Dec 27, 2022

Codecov Report

Merging #3475 (6010cfe) into develop (e2a8464) will decrease coverage by 0.14%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #3475      +/-   ##
===========================================
- Coverage    11.23%   11.09%   -0.15%     
===========================================
  Files          261      262       +1     
  Lines        12670    12830     +160     
===========================================
  Hits          1424     1424              
- Misses       11246    11406     +160     
Impacted Files Coverage Δ
...th_app/lib/background/background_task_details.dart 0.00% <0.00%> (ø)
...smooth_app/lib/data_models/up_to_date_changes.dart 0.00% <0.00%> (ø)
...pp/lib/pages/product/common/product_refresher.dart 1.96% <0.00%> (ø)
...oth_app/lib/pages/product/edit_new_packagings.dart 0.00% <0.00%> (ø)
...mooth_app/lib/pages/product/edit_product_page.dart 0.50% <0.00%> (-0.02%) ⬇️
...th_app/lib/pages/product/ocr_packaging_helper.dart 0.00% <ø> (ø)
...mooth_app/lib/pages/product/simple_input_page.dart 0.00% <0.00%> (ø)
...oth_app/lib/pages/product/simple_input_widget.dart 0.00% <0.00%> (ø)
...smooth_app/lib/query/paged_user_product_query.dart 2.38% <0.00%> (ø)
packages/smooth_app/lib/query/product_query.dart 7.50% <0.00%> (-0.61%) ⬇️
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@teolemon teolemon added the ✏️ Editing - Packaging input Related to the structured input of food packaging. label Dec 27, 2022
result.status != ProductResultV3.statusWarning) {
throw Exception('Could not save product - ${result.errors}');
}
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit confused about the return statement here, do you think it's needed here ?
Suppose I am offline now and I did some edits to the product name and then to this packagings
So when I connect back to the internet, the first block ie the code from if condition would run, and then after successful, it would simply return and won't do the save query for the rest of the changes,

Is there something I am missing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't merge changes, and just save them sequentially one by one.
In the case we want to save packagings, we are going to save only this field. Therefore only in api v3, and when it's done there's nothing else to do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't merge changes, and just save them sequentially one by one.

Thanks for the answer, now it's clear

@monsieurtanuki
Copy link
Contributor Author

Great for the quick turnaround @monsieurtanuki 👏 Are Weight of one empty unit (g)and Quantity of product contained per unit causing any issues ?

They are not in off-dart.

@teolemon
Copy link
Member

ok @monsieurtanuki, I have filed a task there

Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality wise, it's a good first step 👍
Good to merge with a technical review from @AshAman999 or @M123-dev

Copy link
Member

@M123-dev M123-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing that worries me here, thanks @monsieurtanuki

}
return;
}
final Status status = await OpenFoodAPIClient.saveProduct(
getUser(),
_product,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we remove the packaging from here, or are they ignored by the older api versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in a previous comment, save v3 can only save packagings, and the other save method can save the rest. So we need both.
Not sure that answers your question, though.

Copy link
Member

@AshAman999 AshAman999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some issues with the theme and others but found out you already have todos left for em
I was trying the build on my emulator and found that the focus node, ie keyboard on the new packaging screen can't be dismissed,
Nothing blocking though, it does the job, We can fix these later on

👍 for merge from my side too

getUser(),
_product,
language: getLanguage(),
country: getCountry(),
);
if (status.status != 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @M123-dev
Just out of curiosity, Can / Should we log this into sentry, Just wanted to make sure and keep a look into how many fails we do incur when saving data, would be helpful in understanding the background sync bug

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Exception will be automatically collected by sentry, but this is to be checked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AshAman999 More broadly, the question is again: what should we do with failing changes? Run them forever? Ignore them? Alert the user?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that a alert would be more subtle for now
At least the user will know that something went wrong

About retires I am not sure that we are going to have so many of those occurrences for failures,

I guess next setry report will reveal these data

@monsieurtanuki monsieurtanuki merged commit 09a982a into openfoodfacts:develop Dec 27, 2022
@monsieurtanuki
Copy link
Contributor Author

Thank you guys for the reviews!
A good first step. It's not over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Editing - Packaging input Related to the structured input of food packaging. 🥫 Product page
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Check needed for return status of server changes Simplistic implementation of the packaging addition
5 participants